<template>
  <section>
    <el-row v-if="errMsg">
      {{errMsg}}
    </el-row>
    <el-row v-else>
      <div v-if="widget.data.physicalAndGrade" v-html="widget.data.physicalAndGrade.attention"></div>
    </el-row>
  </section>
</template>

<script>

  import {mapActions} from 'vuex'

  export default {
    name: "page-tizhi-e",
    props: ['reportData', 'widget', 'showConfDialog'],
    data(){
      return {
        errMsg:null
      }
    },
    created() {

      if(Object.getOwnPropertyNames(this.widget.data).length < 2 ){
        if(!this.reportData.data.physical ||!this.reportData.data.physicalGrade){
          this.errMsg = '体检数据不满足此控件要求';
        }else {
          this.widget.data.physical = this.reportData.data.physical
          this.widget.data.physicalGrade = this.reportData.data.physicalGrade
          this.loadData()
        }
      }
    },
    methods:{
      ...mapActions({
        fetch: 'fetch'
      }),
      loadData(){
        this.fetch({name:'getPhysicalAndGrade',data:{physicalId:this.reportData.data.physical.id,gradeId:this.reportData.data.physicalGrade.id}})
          .then(res=>{
            //保存并显示
            this.widget.data.physicalAndGrade = res
            this.$emit('done',this.widget.data)
          }).catch(err=>{
            this.errMsg = err.errMsg
        })
      }
    }
  }
</script>

<style scoped>

</style>
